package ws.db.sql;

/**
 * SelectTopRecordsSQL class provide the select top records SQL.
 * */
public class SelectTopRecordsSQL extends SelectSQL {
	
	protected int count;
	
	public SelectTopRecordsSQL(String m_table,String[] m_columns,
						int m_count){
		super(m_table,m_columns);
		count = m_count;
	}
	
	public SelectTopRecordsSQL(String m_table, String m_where,
							String[] m_columns, int m_count){
		super(m_table,m_where,m_columns);
		count = m_count;
	}
	
	public SelectTopRecordsSQL(String m_table,String m_where,
								String m_order,String[] m_columns,
								int m_count){
		super(m_table,m_where,m_order,m_columns);
		count = m_count;
	}
	
	/**
	 * Provoid such as "select top 4 columns1,columns2 from Temptable where a=b ;" SQL.
	 * @param:
	 * 		void
	 * @return:
	 * 		String - the select top records sql.
	 * 
	 * */
	@Override
	public String getSQL() {
		// TODO Auto-generated method stub
		StringBuffer sql = new StringBuffer();
		sql.append("select top "+count+"  ");
		constructColumns(sql,columns);//��������
		sql.append(" from ");
		sql.append(table);
		dealwithWhereOrder(sql,where,order);
		sql.append(";");
		return sql.toString();
	}

}
